using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace WOWEquipOptimizer
{
    class Program
    {
        public static MainWindow mainWindow;
        public static  Dictionary<string, List<string>> ClassBuildDictionary = new Dictionary<string, List<string>>();
        [STAThread]
        // automatical parsing of assembly method full names to gather classes and builds.
        static void Main(string[] args)
        {
            Enchant.InitEnchants();
            Character.LoadLists();
            Database myDB = new Database();
            Assembly myAsm = Assembly.GetExecutingAssembly();
            Type[] myTypes = myAsm.GetTypes();
            for (int i = 0; i < myTypes.Length; i++)
            {
                Type curType = myTypes[i];
                string fname = curType.FullName;
                if (fname == null) continue;
                string[] sub = fname.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                if (sub.Length != 3) continue;
                try
                {
                    Enum.Parse(typeof(CharacterClass), sub[1], true);
                    if (!Program.ClassBuildDictionary.ContainsKey(sub[1]))
                    {
                        List<string> mylist = new List<string>();
                        mylist.Add(sub[2]);
                        Program.ClassBuildDictionary.Add(sub[1], mylist);
                    }
                    else
                    {
                        Program.ClassBuildDictionary[sub[1]].Add(sub[2]);
                    }
                }
                catch
                {
                }

            }
            mainWindow = new MainWindow();
            mainWindow.SetupClassBox();
            mainWindow.ShowDialog();
        }
    }
}
